--[[
 * 每n名生存的队友(或敌人)都可以使属性增加n%
 ]]
---@class BuffEffect27 : BaseBuffEffect
BuffEffect27 = ClientFight.CreateClass("BuffEffect27", ClientFight.BaseBuffEffect)
local t = BuffEffect27
t.BUFF_EFFECT_PARAMETERS_21_ = "BUFF_EFFECT_PARAMETERS_21_"
---@param fight Fight
---@param buff FighterBuff
function t:action(fight, buff, ...)
    local parameters = {...}
    local fighter = buff.target;
    local team = null;
    -- [0,1,15,500]
    if (buff.buffBean.f_BuffEffectValue[1] == 0) then
        team = fight.teams[fighter.teamIndex];
    else
        team = fight.teams[3 - fighter.teamIndex];
    end

    local aliveAmount = 0;
    for k, teamFighter in pairs(team.fighters) do
        if (teamFighter:isSummons() and not teamFighter.isRealSummons()) then
            goto continue;
        end
        if (teamFighter:isDie()) then
            goto continue;
        end
        if (teamFighter.fighterId == fighter.fighterId) then
            goto continue;
        end
        aliveAmount = aliveAmount + 1;
        ::continue::
    end
    local times = aliveAmount / buff.buffBean.f_BuffEffectValue[2];
    if (times > 0) then
        local attrType = buff.buffBean.f_BuffEffectValue[3];
        local addVal = buff.buffBean.f_BuffEffectValue[4] * buff.overlay;

        buff.attributes.attributes[attrType] = addVal * times;

        SkillRoleMgr.savePathFile("[" .. fight.frame .. "][EFFECT]Fighter " .. buff.target.fighterId .. " Buff:"
                .. buff.modelId .. "增加属性(" .. attrType .. ")" .. addVal * times .. "  每n名生存的队友(或敌人)都可以使属性增加n%");
    end
    ClientFight.BaseBuffEffect.action(self, fight, buff, parameters);
    return IBuffEffect.SUCCESS_ATTRI_HAS_CHANGE;
end

t.New()